<div class="t_2">
     <div class="fl"><?=$this->node_name?></div>
     <div class="fr add_form"><a href="javascript:;" id="add_table"></a></div>
</div>
<div class="order_show" id="info_form">
     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">
		<tr>
			<form id="form">
			<td style="text-align:center" colspan="3">
				<select name="class_id">
					<option value="">选择分类</option>
					<?php foreach((array)$this->product_class as $class): ?>
					<option value='<?=$class['class_id']?>'><?=$class['class_name']?></option>
					<?php endforeach; ?>
				</select>
				名称：<input name="keyword" />
				<input type="submit" id="" value="搜索"/>
			</td>
			</form>
		</tr>
		<tr>
			<td style="text-align:center" width="45%">
				<select size="20" multiple="multiple" style="width:100%" id="left_select">
				</select>
			</td>
			<td style="text-align:center" valign="center">
				<input value="添加推荐 >>" id="add" type="button"/>
				<input value="<< 取消推荐" id="remove" type="button"/>
			</td>
			<td style="text-align:center" width="45%">				
				<select size="20" style="width:100%" id="right_select">
					<?php foreach((array)$this->recommend as $p): ?>
					<option value="<?=$p['product_id']?>"><?=$p['name']?></option>
					<?php endforeach; ?>
				</select>
			</td>
		</tr>
     </table>
</div>
<script>
function disall() {
	$('input').attr('disabled','disabled');
	$('select').attr('disabled','disabled');
}
function undisall() {
	$('input').removeAttr('disabled');
	$('select').removeAttr('disabled');
}
$(function(){
	$('#form').submit(function(){
		var data = $(this).serialize();
		disall();
		$.post(location.href+'&act=getlist',data,function(data){
			undisall();
			$('#left_select').html(data);
			if (data == '')
			{
				alert('没有找到任何符合条件的数据或目标库存商品已推荐给了当前用户');
			}
		});
		return false;
	});

	$('#add').click(function(){
		var lo = $('#left_select option:selected');
		if (!lo.val())
		{
			alert('请选择商品');
			return false;
		}
		var ids = new Array();
		lo.each(function(i,n){
			ids.push(n.value);
		});

		disall();		
		$.post(location.href+'&act=add',{ids:ids},function(data){
			undisall();
			lo.appendTo('#right_select');
		});
	});

	$('#remove').click(function(){
		var ro = $('#right_select option:selected');
		if (!ro.val())
		{
			alert('请选择商品');
			return false;
		}

		var ids = new Array();
		ro.each(function(i,n){
			ids.push(n.value);
		});

		disall();

		$.post(location.href+'&act=remove',{ids:ids},function(){
			undisall();
			ro.remove();
		});
	});
});
</script>